/**
 * Project of Vehicle Routing Problem with Time Windows implements 
 * some of well-known algorithms for solving VRPTW and presents new 
 * one.
 *
 * @author Michal Drobny  
 */
package logic.location;

/**
 * Represents the Euclidean location. The location in Euclidean space can be
 * described by only 2 values - X and Y axis. A distance to another Euclidean
 * location can be easy calculated by Pythagoras formula.
 * 
 * @author Michal Drobny
 * @date 16.10.2014
 */
public class EuclideanLocation extends Location {

	private final int X;
	private final int Y;
	
	/**
	 * Constructor.
	 * @param x The x-axis
	 * @param y The y-axis
	 */
	public EuclideanLocation(int x, int y) {
		super();
		X = x;
		Y = y;
	}

	/**
	 * @return the x
	 */
	public int getX() {
		return X;
	}

	/**
	 * @return the y
	 */
	public int getY() {
		return Y;
	}

	@Override
	public Double getDistanceTo(Location o) {
		if (!(o instanceof EuclideanLocation))
			return -1d;
		
		EuclideanLocation other = (EuclideanLocation) o;
		
		return Math.sqrt(Math.pow(getX() - other.getX(), 2)
				+ Math.pow(getY() - other.getY(), 2));
	}
	
	@Override
	public Location clone() {
		return new EuclideanLocation(getX(), getY());
	}
}